<template>
  <a-input-number v-bind="$attrs" :value="fakeValue" style="width: 100%" @change="onChange" />
</template>
<script>
export default {
  // 继承
  name: 'SInputNumber',
  props: {
    modelValue: {
      required: false
    }
  },
  emits: ['change', 'update:modelValue'],
  data() {
    return {
      fakeValue:
        this.modelValue || this.modelValue == 0
          ? typeof this.modelValue == 'string'
            ? parseInt(this.modelValue)
            : this.modelValue
          : undefined
    }
  },
  watch: {
    modelValue(val) {
      this.fakeValue = val || val == 0 ? (typeof val == 'string' ? parseInt(val) : val) : undefined
    }
  },
  methods: {
    onChange(e) {
      this.$emit('update:modelValue', e)
      this.$emit('change', e)
    }
  }
}
</script>
